"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var tag_1 = require("./tag");
var coupons_service_1 = require("../../../lib/service/admin/coupons.service");
var TagComponent = /** @class */ (function () {
    function TagComponent(router, couponsService) {
        this.router = router;
        this.couponsService = couponsService;
        this.currentPage = 1;
        this.itemsPerPage = 12;
        this.isShow = false;
        this.tagList = new tag_1.TagList();
        this.tagInfo = new tag_1.TagInfo();
        this.addTag = new tag_1.AddTag();
        this.editTag = new tag_1.EditTag();
        this.name = '';
        this.model = '';
        this.orderField = '';
        this.orderSort = '';
    }
    TagComponent.prototype.ngOnInit = function () {
        this.getTagList();
    };
    TagComponent.prototype.getTagList = function () {
        var _this = this;
        this.couponsService.getCouponsTagList(this.currentPage, this.itemsPerPage).subscribe(function (data) {
            if (data.code === 2000) {
                _this.tagList.list = data.data.data;
                _this.totalItems = data.data.total;
            }
        });
    };
    TagComponent.prototype.getTagInfo = function (obj) {
        this.editTag.card_coupons_tag_uuid = obj.card_coupons_tag_uuid;
        this.editTag.name = obj.card_coupons_tag_name;
        console.log(this.editTag);
    };
    TagComponent.prototype.addCouponsTagSubmit = function () {
        var _this = this;
        this.couponsService.addCouponsTag(this.addTag).subscribe(function (data) {
            if (data.code === 2000) {
                _this.type = 'success';
                _this.message = '添加成功';
                _this.isShow = true;
                _this.addModal.hide();
                _this.getTagList();
            }
        });
    };
    TagComponent.prototype.editCouponsTagSubmit = function () {
        var _this = this;
        console.log(this.editTag);
        this.couponsService.editCouponsTag(this.editTag).subscribe(function (data) {
            if (data.code === 2000) {
                _this.type = 'success';
                _this.message = '修改成功';
                _this.isShow = true;
                _this.editModal.hide();
                _this.getTagList();
            }
        });
    };
    TagComponent.prototype.pageChanged = function (event) {
        window.scrollTo(0, 0);
        this.currentPage = event.page;
        this.getTagList();
        //this.getTemplateTypeList(event.page,this.searchData)
    };
    TagComponent.prototype.promptIsShow = function (event) {
        this.isShow = event;
    };
    __decorate([
        core_1.ViewChild('addModal')
    ], TagComponent.prototype, "addModal", void 0);
    __decorate([
        core_1.ViewChild('editModal')
    ], TagComponent.prototype, "editModal", void 0);
    TagComponent = __decorate([
        core_1.Component({
            selector: 'app-coupons-tag',
            templateUrl: './tag.component.html',
            styleUrls: ['./tag.component.scss'],
            providers: [coupons_service_1.CouponsService]
        })
    ], TagComponent);
    return TagComponent;
}());
exports.TagComponent = TagComponent;
